package com.syb.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author youkun
 * @see hibernate ��ҳ������
 *
 */

public class PageResults<T>{
	
	 // 当前页数
    private int pageNo;
 
    // 当前页
    private int currentPage;
 
    // 每页显示的数量
    private int pageSize;
 
    // 总记录页数
    private int totalCount;
 
    // 总页数
    private int pageCount;
 
    // 结果集
    private List<T> results;
    
    //首页
    private int startindex;
    
    private Map<String,String> paramMap = new HashMap<String,String>();
 
    public int getPageCount() {
        return  pageCount = totalCount % getPageSize() == 0 ? totalCount / getPageSize()
                : totalCount / getPageSize() + 1;
    }
 
    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }
 
    public int getPageNo() {
    	return this.pageNo<1 ? 1 : pageNo;
    	
    }
 
    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }
 
    public List<T> getResults() {
        return results;
    }
 
    public void setResults(List<T> results) {
        this.results = results;
    }
 
    public int getCurrentPage() {
        return this.currentPage <= 1 ? 0 : (currentPage-1)*getPageSize();
    }
 
    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }
 
    public int getPageSize() {
        return  this.pageSize = pageSize <= 0 ? 10 : pageSize;
    }
 
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize <= 0 ? 10 : pageSize;
    }
 
    public int getTotalCount() {
        return totalCount;
    }
 
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
 
    public void resetPageNo() {
        pageNo = currentPage + 1;
        pageCount = totalCount % pageSize == 0 ? totalCount / pageSize
                : totalCount / pageSize + 1;
    }

	public Map<String, String> getParamMap() {
		return paramMap;
	}

	public void setParamMap(Map<String, String> paramMap) {
		this.paramMap = paramMap;
	}

	public int getStartindex() {
		return 1;
	}

	public void setStartindex(int startindex) {
		this.startindex = startindex;
	}
    

}
